#include "stdafx.h"
#include "Hooks.h"

extern HHOOK g_callwndretproc_hook_handle;

LRESULT CALLBACK CallWndRetProc(      
    int nCode,
    WPARAM wParam,
    LPARAM lParam
)
{
	if (nCode == HC_ACTION)
	{
		//OutputDebugString("Inside Action");
		PCWPRETSTRUCT pStruct = (PCWPRETSTRUCT)lParam;
		
		{
			HDC hdc;

			hdc = GetDC(NULL);
			//	Initializing original object
			HGDIOBJ original = NULL;

			//	Saving the original object
			original = SelectObject(hdc,GetStockObject(DC_PEN));

			//	Rectangle function is defined as...
			//	BOOL Rectangle(hdc, xLeft, yTop, yRight, yBottom);

			//	Drawing a rectangle with just a black pen
			//	The black pen object is selected and sent to the current device context
			//  The default brush is WHITE_BRUSH
			SelectObject(hdc, GetStockObject(BLACK_PEN));
			Rectangle(hdc,0,0,200,200);

			//	Select DC_PEN so you can change the color of the pen with
			//	COLORREF SetDCPenColor(HDC hdc, COLORREF color)
			SelectObject(hdc, GetStockObject(DC_PEN));

			//	Select DC_BRUSH so you can change the brush color from the 
			//	default WHITE_BRUSH to any other color
			SelectObject(hdc, GetStockObject(DC_BRUSH));

			//	Set the DC Brush to Red
			//	The RGB macro is declared in "Windowsx.h"
			SetDCBrushColor(hdc, RGB(255,0,0));

			//	Set the Pen to Blue
			SetDCPenColor(hdc, RGB(0,0,255));

			//	Drawing a rectangle with the current Device Context	
			Rectangle(hdc,100,300,200,400);

			//	Changing the color of the brush to Green
			SetDCBrushColor(hdc, RGB(0,255,0));
			Rectangle(hdc,300,150,500,300);

			//	Restoring the original object
			SelectObject(hdc,original);

			ReleaseDC(NULL, hdc);
		}
	}
	LRESULT val = CallNextHookEx(g_callwndretproc_hook_handle,nCode,wParam,lParam);
	return val;
}
